package cn.edu.sdjzu.xg.eagle.fastjon;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import java.io.IOException;
import java.util.List;

public class Main {
    public static void main(String[] args) throws IOException {

        String json_obj_str = TxtHelper.readTxt("files/" + "paginationObject.txt");

        JSONObject pagination_json_obj = JSON.parseObject(json_obj_str);

        Object pageSize_obj = pagination_json_obj.get("pageSize");
        Object pageNo_obj = pagination_json_obj.get("pageNo");

        Pagination pagination2 = JSON.parseObject(json_obj_str, Pagination.class);
        int pageNo2 = pagination2.getPageNo();
        int pageSize2 = pagination2.getPageSize();
        System.out.println(pageNo2);
        System.out.println(pageSize2);
        String json_array_str = TxtHelper.readTxt("files/" + "conditionArray.txt");
        System.out.println("JSON 字符串: " + json_array_str);

        JSONObject json_obj = JSON.parseObject(json_array_str);
        System.out.println("解析为 JSONObject: " + json_obj);

        JSONArray conditionListJson = json_obj.getJSONArray("conditionList");
        System.out.println("conditionList JSON 数组: " + conditionListJson);

        List<Condition> conditionList = JSON.parseArray(conditionListJson.toJSONString(), Condition.class);
        System.out.println("conditionList Java 对象: " + conditionList);

    }
}